import http from '@/utils/http'

const BASE_URL = '/system/factorySite'

export interface FactorySiteResp {
  id: string
  name: string
  avatar: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface FactorySiteDetailResp {
  id: string
  name: string
  avatar: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface FactorySiteQuery {
  name: string
  sort: Array<string>
}
export interface FactorySitePageQuery extends FactorySiteQuery, PageQuery {}

/** @desc 查询厂区信息列表 */
export function listFactorySite(query: FactorySitePageQuery) {
  return http.get<PageRes<FactorySiteResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询厂区信息详情 */
export function getFactorySite(id: string) {
  return http.get<FactorySiteDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 查询厂区信息详情 */
export function factorySiteAndBuildingList() {
  return http.get(`/system/factorySite/sitebuildinglist`)
}

/** @desc 查询厂区和办公楼信息详情 */
export function factorySiteAndsitebuildingList() {
  return http.get(`/system/factorySite/siteBuildingListAllUser`)
}

/** @desc 新增厂区信息 */
export function addFactorySite(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改厂区信息 */
export function updateFactorySite(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除厂区信息 */
export function deleteFactorySite(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出厂区信息 */
export function exportFactorySite(query: FactorySiteQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
